﻿namespace PrismEx.SampleApp.Modules.SimpleNavigation
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.Composition;
    using System.Windows.Input;

    using Microsoft.Practices.Prism.Commands;
    using Microsoft.Practices.Prism.Events;

    using PrismEx.Base;
    using PrismEx.Events;
    using PrismEx.Events.Navigation;

    [Export]
    public class SimpleNavigationViewModel : Observable
    {
        private readonly IEventAggregator eventAggregator;

        [ImportingConstructor]
        public SimpleNavigationViewModel(IEventAggregator eventAggregator)
        {
            this.eventAggregator = eventAggregator;
        }

        public IEnumerable<NavigationLink> Links
        {
            get
            {
                return new[] { new NavigationLink()
                    {
                        Text = "Link 1", 
                        Uri = new Uri("", UriKind.Relative)
                    } };
            }
        }

        public ICommand NavigateCommand
        {
            get
            {
                return new DelegateCommand<Uri>(p => eventAggregator.Publish(new InjectInstanceIntoRegionEvent { RegionName = "SimpleNavigationSubRegion", Instance = "Hello World" }));
            }
        }

        public class NavigationLink
        {
            public string Text { get; set; }

            public Uri Uri { get; set; }
        }
    }
}